/**
 * Created by huotaol on 2017/4/27.
 */

import * as types from "../../constant/ActionType";

const initCollectionState = {
    count: 0,
};

function collection(state = Object.assign({}, initCollectionState), action) {
    switch (action.type) {
        case types.MINE_COLLECTION:
            return Object.assign({}, state, {count: action.count,});
            break;
        default:
            return state;
            break;
    }
}

const initAuctionState = {
    count: 0,
};

function auction(state = Object.assign({}, initAuctionState), action) {
    switch (action.type) {
        case types.MINE_AUCTION:
            return Object.assign({}, state, {count: action.count,});
            break;
        default:
            return state;
            break;
    }
}

const initViewState = {
    count: 0,
};

function view(state = Object.assign({}, initViewState), action) {
    switch (action.type) {
        case types.MINE_VIEW:
            return Object.assign({}, state, {count: action.count,});
            break;
        default:
            return state;
            break;
    }
}

const initUserData = {
    id: 0,
    token: '',
    phone: '',
    info: '',
};

function userData(state = Object.assign({}, initUserData), action) {
    switch (action.type) {
        case types.USER_DATA:
            return Object.assign({}, state, {
                id: action.id,
                token: action.token,
                phone: action.phone,
                info: action.info,
            });
        default:
            return state;
    }
}

export default {collection, auction, view, userData};